package org.bridgen.runtime.log;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 
 * @author Emma Söderberg <emma add cs.lth.se>
 *
 */

public class RecoveryLog {

	private Collection<RecoveryAction> actionList;

	public RecoveryLog() {
		actionList = new ArrayList<RecoveryAction>();
	}

	/**
	 * Add a new recovery action to the log
	 * 
	 * @param action
	 *            The action to add
	 */
	public void addAction(RecoveryAction action) {
		actionList.add(action);
	}

	/**
	 * Replaces the content of this log with the content of the given log
	 * 
	 * @param log
	 *            The new log
	 */
	public void replaceWith(RecoveryLog log) {
		actionList = log.actionList;
	}

	public Collection<RecoveryAction> getActionList() {
		return actionList;
	}

	/**
	 * Clears this log
	 */
	public void clear() {
		actionList.clear();
	}

	public String toString() {
		String content = "";
		for (RecoveryAction action : actionList) {
			content += "ACTION: " + action + "\n";
		}
		return content;
	}
}
